let num: string = '3' 
let div = document.getElementById('home')
div.innerText = num


let inp1 = document.getElementById('inp1')
let inp2 = document.getElementById('inp2')
let res = document.getElementById('res')

function enterClick() {
	console.log(inp1.value)
	add(inp1.value, inp2.value)
}

function add(x: string, y: string): void {
	res.innerText = x + y
}

// 数组泛型
let arr: Array<number> = [1,2,3,4]
// 数组泛型(联合声明)
let arr1: Array<string | number> = [1,2,3,'a']

function addPlus(x: number = 1, y?: number): number {
	return x + y
}

function add1<T>(x: T, y?: T): T[] {
	return [x, y]
}

// 泛型的约束
interface stringLen {
	length: number
}

function f1<T extends stringLen>(a: T): number {
	return a.length
}

f1<string>('string')